package com.example.ch12springbootwar.controller;

import com.example.ch12springbootwar.model.UserVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 何杨谊
 * @description: TODO
 * @date 2022/4/3 23:20
 */
@RestController()
@RequestMapping("/api/user")
public class UserController {

    @GetMapping("/info")
    public UserVO info() {
        UserVO user = new UserVO();
        user.setId(999);
        user.setName("小何同學");
        return user;
    }

    @GetMapping("/items")
    public List<UserVO> items(){
        List<UserVO> vos=new ArrayList<>();
        for (int i=0;i<10;++i){
            UserVO vo=new UserVO();
            vo.setId(i);
            vo.setName("小何同学-"+i);
            vos.add(vo);
        }
        return vos;
    }

}
